package cn.iocoder.yudao.module.engine.util;

import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.module.engine.model.engine.EngineOutputData;
import cn.iocoder.yudao.module.engine.enums.EnumAudioType;
import cn.iocoder.yudao.module.resource.api.enums.MessageSourceTypeEnum;
import cn.iocoder.yudao.module.resource.api.model.AudioDTO;

public class EngineConvertUtils {

    public static EngineOutputData.Audio toEngineOutputData(String fromMessage, String chatId,
                                                            MessageSourceTypeEnum messageSendType,
                                                            EnumAudioType audioType, AudioDTO audioDto) {
        if (audioDto == null) {
            return null;
        }

        final EngineOutputData.Audio audio = new EngineOutputData.Audio();
        audio.setChatId(chatId);
        audio.setAudioType(audioType);
        audio.setMessageSendType(messageSendType);
        audio.setAudioId(String.valueOf(audioDto.getAudioId()));
        audio.setAudioDesc(audioDto.getAudioText());
        audio.setAudioUrl(audioDto.getFileUrl());
        audio.setTagNameList(audioDto.getTagNameList());
        audio.setKeywordNameList(audioDto.getKeywordNameList());
        audio.setRelationType(audioDto.getRelationType());
        audio.setFromMessage(fromMessage);
        audio.setMessageId(IdUtil.objectId());
        return audio;
    }

}
